package com.fin.zw.aiqas.entity;


import com.fin.zw.aiqas.enums.*;
import lombok.Data;
import org.hibernate.annotations.Table;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

@Entity
@Table(appliesTo = "task_info", comment = "任务管理")
@Data
public class TaskInfo extends BaseEntity {

    @Column(columnDefinition = "varchar(200) COMMENT '任务名称'")
    private String name;

    //任务类型 手动/自动
    @Column(columnDefinition = "varchar(20) COMMENT '任务类型'")
    @Enumerated(EnumType.STRING)
    private TaskType taskType;

    //任务类型为自动
    @Column(columnDefinition = "varchar(10) COMMENT '自动质检时间类型'")
    @Enumerated(EnumType.STRING)
    private TaskTimeType checkTimeType;

    //任务类型为自动/手动
    @Column(columnDefinition = "varchar(10) COMMENT '质检具体时间'")
    private String taskCron;

    //定时任务状态  停用/启用
    @Column(columnDefinition = "varchar(20) COMMENT '定时任务状态  停用/启用  '")
    @Enumerated(EnumType.STRING)
    private Status status = Status.STOP;

    @Column(columnDefinition = "varchar(20) COMMENT '运行状态'")
    @Enumerated(EnumType.STRING)
    private TaskStatus runStatus = TaskStatus.READY;

    @Column(columnDefinition = "datetime COMMENT '任务开始时间'")
    private Date startTime;

    @Column(columnDefinition = "datetime COMMENT '任务结束时间'")
    private Date endTime;

    //通话时长
    @Column(columnDefinition = "varchar(20) COMMENT '通话时长类型'")
    @Enumerated(EnumType.STRING)
    private LogicalCalculus durationLogic;
    /**
     * 大于/小于/自定义的开始数字
     */
    @Column(columnDefinition = "varchar(20) COMMENT '通话时长刷选时间'")
    private BigDecimal num;
    //自定义的结束数字
    @Column(columnDefinition = "varchar(20) COMMENT '通话时长筛选结束时间'")
    private BigDecimal endNum;

    @Column(columnDefinition = "varchar(20) COMMENT '呼叫方向'")
    @Enumerated(EnumType.STRING)
    private Direction direction;

    @Column(columnDefinition = "decimal(18,4) COMMENT '抽检比例'")
    private BigDecimal checkProp;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "task_rule", joinColumns = @JoinColumn(name = "task_id"), inverseJoinColumns = @JoinColumn(name = "rule_id"))
    private Set<RuleInfo> ruleInfoSet;

    @Column(columnDefinition = "varchar(500) COMMENT '任务文件路径'")
    private String taskFilePath;

    @Column(columnDefinition = "bigint(64) COMMENT '场景ID'")
    private Long scenesInfoId;

    @Column(columnDefinition = "int(64) COMMENT '并发数'")
    private int threadNum = 4;

}
